<?php $this->load->view('navmenu');?>
<script type="text/javascript" charset="utf-8">
    // dynamic table
    jQuery('#dyntable').dataTable({
    "sPaginationType": "full_numbers",
    "aaSortingFixed": [[0,'asc']],
    "fnDrawCallback": function(oSettings) {
    jQuery.uniform.update();
    }
    });
</script>
<div class="maincontent">
        	<div class="contentinner">
                	<center><?php echo $this->session->flashdata('msg'); ?></center>
             <h4 class="widgettitle nomargin shadowed">Tambah User</h4>
                <div class="widgetcontent bordered shadowed nopadding">
                    <form class="stdform stdform2" method="post" action="<?php echo base_url()?>index.php/user/saveUser">
                            <p>
                                <label>Nama</label>
                                <span class="field"><input type="text" name="nama" id="nama" class="input-xlarge" <?php if($selectedUser != ""){ echo 'value="'.$selectedUser['nama'].'"'; }?>/></span>
                            </p>
                   
                            <p>
                                <label>Username</label>
                                <span class="field"><input type="text" name="username" id="username" class="input-xlarge" <?php if($selectedUser != ""){ echo 'value="'.$selectedUser['username'].'" readonly'; }?> /></span>
                            </p>
                            
                            <p>
                                <label>Password</label>
                                <span class="field"><input type="password" name="password" id="password" class="input-xlarge" <?php if($selectedUser != ""){ echo 'value="'.$selectedUser['password'].'"'; }?>/></span>
                            </p>
                            
                            <p>
                                <label>Email</label>
                                <span class="field"><input type="mail" name="mail" id="mail" class="input-xlarge" <?php if($selectedUser != ""){ echo 'value="'.$selectedUser['mail'].'"'; }?>/></span>
                            </p>
                            
                            <p>
                                <label>Level</label>
                                <span class="field"><select name="level" id="selection2" class="uniformselect">
                                    <option value="1" <?php if($selectedUser['level'] == 1){ echo 'selected'; }else{}?>>Super Admin</option>
                                    <option value="2" <?php if($selectedUser['level'] == 2){ echo 'selected'; }else{}?>>Kontraktor</option>
                                    <option value="3" <?php if($selectedUser['level'] == 3){ echo 'selected'; }else{}?>>Konsultan</option>
                                    <option value="4" <?php if($selectedUser['level'] == 4){ echo 'selected'; }else{}?>>Owner</option>
                                    <option value="5" <?php if($selectedUser['level'] == 5){ echo 'selected'; }else{}?>>Guest</option>
                                </select></span>
                            </p>
                                                    
                            <p class="stdformbutton">
                                <button type="submit" class="btn btn-primary">Submit Button</button>
                                <button type="reset" class="btn">Reset Button</button>
                            </p>
                        </form>
                    </div><!--widgetcontent-->
            	<h4 class="widgettitle">Daftar User</h4>
            	<table class="table table-bordered" id="dyntable">
                    <thead>
                        <tr>
                            <th class="center">No</th>
                            <th class="center">Username</th>
                            <th class="center">Nama</th>
                            <th class="center">Email</th>
                            <th class="center">Level</th>
                            <th class="center">Action</th>
                        </tr>
                    </thead>
                    <tbody>
					<?php $i=1;?>
					<?php foreach($users as $row):?>
					<?php
						if($row['level'] == 1)
						{
							$level = 'Super Admin';
						}
						elseif($row['level'] == 2)
						{
							$level = 'Kontraktor';
						}
						elseif($row['level'] == 3)
						{
							$level = 'Konsultan';
						}
						elseif($row['level'] == 4)
						{
							$level = 'Owner';
						}
						else
						{
							$level = 'Guest';
						}
					?>
                        <tr class="gradeX">
                            <td class="center"><?=$i?></td>
                            <td class="center"><?=$row['username']?></td>
                            <td class="center"><?=$row['nama']?></td>
                            <td class="center"><?=$row['mail']?></td>
                            <td class="center"><?=$level?></td>
                            <td class="center"><a href="<?php echo base_url();?>index.php/user/usersList/<?=$row['username']?>/<?=$row['level']?>"/><i class="icon-edit"></i></a> | <a href="<?php echo base_url();?>index.php/user/deleteUser/<?=$row['username']?>/<?=$row['level']?>"><i class="icon-remove"></i></a></td>
                        </tr>
					<?php $i++;endforeach; ?>
                    </tbody>
                </table>
       
            </div><!--contentinner-->
        </div><!--maincontent-->